﻿/* tslint:disable:jsdoc-format max-line-length */
// warning: Generated code! Do not change!
module App {
	"use strict";
	export class AjaxHelper {
		public baseUrl: string;
		constructor(baseUrl: string) {
			if (baseUrl.match(/\/$/)) {
				baseUrl += "/";
			}
			this.baseUrl = baseUrl;
		}

		request(url: string, httpVerb: string, data?: any): JQueryXHR {
			var settings: JQueryAjaxSettings = {
				cache: false,
				async: true,
				timeout: 2000,
				dataType: "json",
				contentType: "application/json",
				type: httpVerb,
				url: this.baseUrl + url
			};

			if (data !== undefined) {
				settings.data = JSON.stringify(data);
			}

			var res = $.ajax(settings);
			return res;
		}
	}

	export class ValuesProxy {
		constructor(public baseUrl: string = "") { }

		cache: boolean = false;
		timeout: number = 2000;
		async: boolean = true;
		ajaxHelper = new AjaxHelper(this.baseUrl);


		Get(): JQueryPromise<Array<string>> {
			var result = this.ajaxHelper.request("api/values/Get", "GET");
			return result;
		}

		GetById(id: number): JQueryPromise<string> {
			var result = this.ajaxHelper.request("api/values/Get?id=" + id, "GET");
			return result;
		}

		Post(/** [FromBody] **/value: string): JQueryPromise<void> {
			var result = this.ajaxHelper.request("api/values/Post", "POST", JSON.stringify(value));
			return result;
		}

		PutById(id: number, /** [FromBody] **/value: string): JQueryPromise<void> {
			var result = this.ajaxHelper.request("api/values/Put?id=" + id, "PUT", JSON.stringify(value));
			return result;
		}

		DeleteById(id: number): JQueryPromise<void> {
			var result = this.ajaxHelper.request("api/values/Delete?id=" + id, "DELETE");
			return result;
		}
	}
}
